<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>绑定class的几种方式</title>    
    <style type="text/css">
        .red{color:#F00}
        .green{color: #0F0}
    </style>
    <link href="style/demo.css" type="text/css" rel="stylesheet" />
</head>
<body>
    <!-- 对象语法 :class="{'active':isActive,'error':isError}"-->
    <div id="app">
        <div class="red">我是红色</div>
        <div class="green">我是绿色</div>             
        <div class="abc" :class="{'active':isActive,'error':isError}">            
        </div>

        
    </div>
    <!-- 数组语法 :class="[activeCls,errorCls]"-->
    <div id="app-2">
        <div :class="[activeCls,errorCls]">
            <p>天降大任</p>
        </div>
        <!-- 三元表达式 -->
        <!-- <div :class="[this.isActive ? activeCls : '',errorCls]"></div> -->
    </div>
    <!-- 条件渲染指令 -->
    <div id="app-3">
      <p v-if="sex === '男'">你是个男生</p>    
      <p v-else-if="sex === '女'">你是个女生</p>    
      <p v-else>你既不是个男生也不是个女生</p>        
    </div>
    <script src="https://unpkg.com/vue/dist/vue.min.js"></script>
    <script>
        var app = new Vue({
            el:"#app",
            data:{                                
                isActive:true,
                isError:false,          
                msg:"高歌一首",
            }
        })
        var app2 = new Vue({
            el:"#app-2",
            data:{                                                
                activeCls:'active',
                errorCls:'error'
            }
        })
        
        var app3 = new Vue({
            el:"#app-3",
            data:{
                sex:'男',
            }
        })
    </script>
</body>
</html>